#include "../scripts/Commands/Admin.pwn"
#include "../scripts/Commands/Anims.pwn"
#include "../scripts/Commands/Lists.pwn"
#include "../scripts/Commands/Fun.pwn"
#include "../scripts/Commands/Dev.pwn"

	CMD:home(playerid, params[])
	{
		msgaF(0xFF00FFFF, "%s returned to %s spawnpoint", GetName(playerid), SpawnNames[rCpos]);
		SetPlayerPos(playerid, SpawnCams[rCpos][6], SpawnCams[rCpos][7], SpawnCams[rCpos][8]);
		SetPlayerVirtualWorld(playerid, 0);
		SetPlayerInterior(playerid, 0);
		SetPlayerSkin(playerid, pInfo[playerid][pI_Skin]);
		TextDrawShowForPlayer(playerid, infobar);
		TextDrawShowForPlayer(playerid, ClockText);

		if(bPlayerGameSettings[playerid]&sumo)bitFalse(bPlayerGameSettings[playerid], sumo);
		if(bPlayerGameSettings[playerid]&brawl)bitFalse(bPlayerGameSettings[playerid], brawl);
		if(bPlayerGameSettings[playerid]&parkour)
		{
			bitFalse(bPlayerGameSettings[playerid], parkour);
			ParkourCheck[playerid]=-1;
			if(IsValidDynamicCP(ParkourCP[playerid]))DestroyDynamicCP(ParkourCP[playerid]);
		}
	    return 1;
	}
	CMD:parkour(playerid, params[])
	{
		bitTrue(bPlayerGameSettings[playerid], parkour);

		SetPlayerPos(playerid, ParkourCPs[0][0], ParkourCPs[0][1], ParkourCPs[0][2]);
		ParkourCheck[playerid]=1;
		ParkourCP[playerid]=CreateDynamicCP(ParkourCPs[1][0], ParkourCPs[1][1], ParkourCPs[1][2], 3.0, _, _, playerid);

		msgaF(LGREEN, "%s Has Gone To Jump Buildings At Parkour", GetName(playerid));
		msg(playerid, YELLOW, "The Timer Is Running! Type "#C_BLUE"/home "#C_YELLOW"to exit");
		ParkourInitialTick[playerid]=GetTickCount();

		return 1;
	}
	CMD:die(playerid, params[])
	{
		SetPlayerHealth(playerid, 0);
		msgaF(0x33AA33AA, "%s Comitted Suicide!", GetName(playerid));
		return 1;
	}
	CMD:spawn(playerid, params[])
	{
		SpawnPlayer(playerid);
		return 1;
	}
	CMD:car(playerid, params[])
	{
	    if(pAdmin(playerid)>0)
		{
			if(bServerGlobalSettings&FreeAdminMode)
			{
		    	TogglePlayerControllable(playerid, false);
				ShowMenuForPlayer(carmenu, playerid);
			}
			else
			{
				if(pAdmin(playerid)>=3)
		    	{
		    		TogglePlayerControllable(playerid, false);
					ShowMenuForPlayer(carmenu, playerid);
				}
			}
		}
		else msg(playerid, RED, "This is an admin command");
		return 1;
	}
	CMD:wep(playerid, params[])
	{
	    if(pAdmin(playerid)>0)
		{
			if(bServerGlobalSettings&FreeAdminMode)
			{
		    	TogglePlayerControllable(playerid, false);
				ShowMenuForPlayer(wepmenu, playerid);
			}
			else
			{
				if(pAdmin(playerid)>=3)
		    	{
		    		TogglePlayerControllable(playerid, false);
					ShowMenuForPlayer(wepmenu, playerid);
				}
				else msg(playerid, RED, "ERROR");
			}
		}
		else msg(playerid, RED, "This is an admin command");
		return 1;
	}
	CMD:f(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&InDM) msg(playerid, RED, "You cannot fix your car in a deathmatch as that would be unfair!");
		else if(bServerGlobalSettings&CmdsDisable)return 0;
		else if(bPlayerGameSettings[playerid]&brawl)return 0;
		else if(bPlayerGameSettings[playerid]&InRace)return 0;
		else
		{
			new veh;
			new Float:x, Float:y, Float:z;
			GetPlayerPos(playerid, x, y, z);
			new Float:vehrot;
			veh = GetPlayerVehicleID(playerid);
			GetVehicleZAngle(veh, Float:vehrot);
			SetVehicleZAngle(veh, Float:vehrot);
			SetVehicleHealth(veh,1000);
			msg(playerid,0x33AA33AA,"Flipped And Fixed");
			PlayerPlaySound(playerid, 1133, x, y, z);
			RepairVehicle(veh);
		}
		return 1;
	}
	CMD:speed(playerid, params[])
	{
	    msgF(playerid, YELLOW, "Speed: %dkm/h", GetPlayerSpeed(playerid));
	    return 1;
	}
	CMD:nos(playerid, params[])
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
		if(IsPlayerInInvalidNosVehicle(playerid, vehicleid))msg(playerid, RED, "NOS Not Available In This Vehicle");
		else if(!IsPlayerInVehicle(playerid, vehicleid))msg(playerid, RED, "You are not in a vehicle idiot.");
		else if(bPlayerGameSettings[playerid]&InRace)msg(playerid, RED, "You cannot use NOS in a race!");
		else AddVehicleComponent(vehicleid, 1010);
		return 1;
	}
	CMD:jet(playerid, params[])
	{
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USEJETPACK);
		return 1;
	}
	CMD:colour(playerid, params[])
	{
		new ColourList[200], tmpstr[16];
	    for(new x;x<sizeof(cArray);x++)
	    {
	        format(tmpstr, 16, "%s\n", cArray[x][colour_name]);
	        strcat(ColourList, tmpstr);
	    }
		ShowPlayerDialog(playerid, d_Colourlist, DIALOG_STYLE_LIST,	"Choose a color for your name:", ColourList, "Select", "Cancel");
		return 1;
	}
	CMD:players(playerid, params[])
	{
		msg(playerid,WHITE,"*************************");
		msgF(playerid,LGREEN,"%d {FFFF00}Players Online",GetPlayersOnline());
		msg(playerid,WHITE,"*************************");
		return 1;
	}
	CMD:admins(playerid, params[])
	{
	    new
			str[500],
			s_str[55],
			admins;
		PlayerLoop(i)
		{
			if(pAdmin(i)>0)
			{
				admins++;
				format(s_str, 50, "%s (level %d - %s)\n", GetName(i), pAdmin(i), AdminName[pAdmin(i)]);
				if(pAdmin(i)==4)strins(s_str, "{AA3333}", 0);
				if(pAdmin(i)==3)strins(s_str, "{FFFF00}", 0);
				if(pAdmin(i)==2)strins(s_str, "{33AA33}", 0);
				if(pAdmin(i)==1)strins(s_str, "{FFFF00}", 0);
				strcat(str, s_str);
			}
		}
	    if(admins==0)msg(playerid, BLUE, "No administrators online");
	    else ShowPlayerDialog(playerid, d_Cmds, DIALOG_STYLE_MSGBOX, "Administrators Currently Online", str, "Close", "");
		return 1;
	}
	CMD:map(playerid, params[])
	{
		new Text:txtSprite1;
		txtSprite1 = TextDrawCreate(200.0, 220.0, "samaps:map"); // Text is txdfile:texture
		TextDrawFont(txtSprite1, 4); // Font ID 4 is the sprite draw font
		TextDrawColor(txtSprite1,0xFFFFFFFF);
		TextDrawTextSize(txtSprite1,200.0,200.0); // Text size is the Width:Height
		TextDrawShowForPlayer(playerid,txtSprite1);
		return 1;
	}
	CMD:sky(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&InDM || bPlayerGameSettings[playerid]&InLobby)
		{
			return 0;
		}
		else
		{
			if(IsPlayerInAnyVehicle(playerid))
			{
				new playerVehicle = GetPlayerVehicleID(playerid);
				new Float:x;
				new Float:y;
				new Float:z;
				GetPlayerPos(playerid, x, y, z);
				SetPlayerPos(playerid, x, y, z+500.0);
				SetVehiclePos(playerVehicle, x, y, z+500.0);
				PutPlayerInVehicle(playerid, playerVehicle, 0);
				GameTextForPlayer(playerid, "Have A nice Fall!", 3000, 5);
			}
			else
			{
				new Float:x;
				new Float:y;
				new Float:z;
				GetPlayerPos(playerid, Float:x, Float:y, Float:z);
				SetPlayerPos(playerid, Float:x, Float:y, Float:z+500.0);
				GameTextForPlayer(playerid, "Have A nice Fall!", 3000, 5);
				GivePlayerWeapon(playerid, Parachute, 1);
			}
		}
		return 1;
	}
	CMD:kickme(playerid, params[])
	{
		Kick(playerid);
		msgaF(PINK, "%s Kicked himself with /kickme", GetName(playerid));
		return 1;
	}
	CMD:beer(playerid, params[])
	{
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_BEER);
		return 1;
	}
	CMD:fag(playerid, params[])
	{
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_SMOKE_CIGGY);
		return 1;
	}
	CMD:wine(playerid, params[])
	{
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_WINE);
		return 1;
	}
	CMD:sprunk(playerid, params[])
	{
		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_DRINK_SPRUNK);
		return 1;
	}
	CMD:sober(playerid, params[])
	{
	    SetPlayerDrunkLevel(playerid, 0);
	    return 1;
	}
	CMD:rand(playerid, params[])
	{
		new r=random(random(random(random(random(random(random(r*r*r*r*r*r^r^r^r^r^r^r^r^r^r^r^r/random((r^r, r*random(r))))))))));
		msgaF(BLUE, "%s Generated a random number... %d", GetName(playerid), random(random(random(random(random(random(random(r))))))));
		return 1;
	}
	CMD:dist(playerid, params[])
	{
		new Float:opx, Float:opy, Float:opz, Float:px, Float:py, Float:pz;
		GetPlayerPos(strval(params), opx, opy, opz);
		GetPlayerPos(playerid, px, py, pz);
		msgF(playerid, GREEN, "Distance To Player: %fm", floatsqroot(((px-opx)*(px-opx))+((py-opy)*(py-opy))+((pz-opz)*(pz-opz))));
		return 1;
	}
	CMD:psave(playerid, params[])
	{
		new Float:px, Float:py, Float:pz, Float:pa, pi=GetPlayerInterior(playerid), pw=GetPlayerVirtualWorld(playerid);
		if(!IsPlayerInAnyVehicle(playerid))
		{
			GetPlayerPos(playerid, px, py, pz);
			GetPlayerFacingAngle(playerid, pa);
		}
		else
		{
			new c = GetPlayerVehicleID(playerid);
			GetVehiclePos(c, px, py, pz);
			GetVehicleZAngle(c, pa);
		}
		pSavePos[playerid][0] = px;
		pSavePos[playerid][1] = py;
		pSavePos[playerid][2] = pz;
		pSavePos[playerid][3] = pa;
		pSavePosExtra[playerid][0] = pi;
		pSavePosExtra[playerid][1] = pw;

		msgF(playerid, YELLOW, "%f x %f x %f Saved! type /b to go back here", px, py, pz);
		return 1;
	}
	CMD:prad(playerid, params[])
	{
	    new fRad;
		sscanf(params, "f", fRad);
		pSavePosExtra[playerid][2]=fRad;
	}
	CMD:b(playerid, params[])
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
		    new playerVehicle = GetPlayerVehicleID(playerid);
			SetVehiclePos(playerVehicle, pSavePos[playerid][0], pSavePos[playerid][1], pSavePos[playerid][2]);
			SetVehicleZAngle(playerVehicle, pSavePos[playerid][3]);
		}
		else SetPlayerPos(playerid, pSavePos[playerid][0], pSavePos[playerid][1], pSavePos[playerid][2]);
		SetPlayerInterior(playerid, pSavePosExtra[playerid][0]);
		SetPlayerVirtualWorld(playerid, pSavePosExtra[playerid][1]);
	 	return 1;
	}
	CMD:createdm(playerid, params[])
	{
		ShowMenuForPlayer(DMcreate, playerid);
		return 1;
	}
	CMD:dmhost(playerid, params[])
	{
		msgF(playerid, YELLOW, "HOST %d", DMhost);
		return 1;
	}
	CMD:radio(playerid, params[])
	{
	    FormatRadioList(playerid);
	    return 1;
	}
FormatRadioList(playerid)
{
	new
		tmpStr[64],
		finalStr[256];
	for(new x;x<sizeof(RadioStreams);x++)
	{
	    format(tmpStr, 64, "%s\n", RadioStreams[x][1]);
	    strcat(finalStr, tmpStr);
	}
	ShowPlayerDialog(playerid, d_RadioList, DIALOG_STYLE_LIST, "Radio Streams", finalStr, "Play", "Stop");
}


//==============================================================VEHICLE COMMANDS

	CMD:engine(playerid, params[])
	{
	    v_Engine(GetPlayerVehicleID(playerid), !v_Engine(GetPlayerVehicleID(playerid)));
		return 1;
	}
	CMD:lights(playerid, params[])
	{
	    v_Lights(GetPlayerVehicleID(playerid), !v_Lights(GetPlayerVehicleID(playerid)));
		return 1;
	}
	CMD:alarm(playerid, params[])
	{
	    v_Alarm(GetPlayerVehicleID(playerid), !v_Alarm(GetPlayerVehicleID(playerid)));
		return 1;
	}
	CMD:bonnet(playerid, params[])
	{
	    v_Bonnet(GetPlayerVehicleID(playerid), !v_Bonnet(GetPlayerVehicleID(playerid)));
		return 1;
	}
	CMD:boot(playerid, params[])
	{
	    v_Boot(GetPlayerVehicleID(playerid), !v_Boot(GetPlayerVehicleID(playerid)));
		return 1;
	}
	CMD:lock(playerid, params[])
	{
		if(!IsPlayerInAnyVehicle(playerid)) msg(playerid, ORANGE, "**You Are Not In A Vehicle");
		else
		{
			PlayerLoop(i)
			SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 1);
			msg(playerid, YELLOW, "**Vehicle Locked");
		}
		return 1;
	}
	CMD:unlock(playerid, params[])
	{
		PlayerLoop(i)
		SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid), i, 0, 0);
		msg(playerid, YELLOW, "**Vehicle Unlocked");
		return 1;
	}
	CMD:neon(playerid, params[])
	{
	    new vehicleid = GetPlayerVehicleID(playerid);
		vehicle_Neon[0] = CreateObject(18648,0,0,0,0,0,0,100.0);
		vehicle_Neon[1] = CreateObject(18648,0,0,0,0,0,0,100.0);
		AttachObjectToVehicle(vehicle_Neon[0], vehicleid, -0.8, 0.0, -0.60, 0.0, 0.0, 0.0);
		AttachObjectToVehicle(vehicle_Neon[1], vehicleid, 0.8, 0.0, -0.60, 0.0, 0.0, 0.0);
		msg(playerid, YELLOW, "Neon Lights Installed");
	    return 1;
	}
	CMD:getspeed(playerid, params[])
	{
		new
			Float:Velocity[3],
			vehicleid = GetPlayerVehicleID(playerid);
		GetVehicleVelocity(vehicleid, Velocity[0], Velocity[1], Velocity[2]);
		msgF(playerid, YELLOW, "You are going at a velocity of X%f, Y%f, Z%f Total Calculated: %f", Velocity[0], Velocity[1], Velocity[2], CalculateVelocity(Velocity[0], Velocity[1], Velocity[2]));
		return 1;
	}
	CMD:boost(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&SpeedBoost)
		{
			bitFalse(bPlayerGameSettings[playerid], SpeedBoost);
			msg(playerid, YELLOW, "Boost Mode off");
		}
		else
		{
			bitTrue(bPlayerGameSettings[playerid], SpeedBoost);
			msg(playerid, YELLOW, "Boost Mode ON! Press the Horn button to boost your car!");
		}
		return 1;
	}
	CMD:jump(playerid, params[])
	{
		if(bPlayerGameSettings[playerid]&JumpBoost)
		{
			bitFalse(bPlayerGameSettings[playerid], JumpBoost);
			msg(playerid, YELLOW, "Jump Mode off");
		}
		else
		{
			bitTrue(bPlayerGameSettings[playerid], JumpBoost);
			msg(playerid, YELLOW, "Jump Mode ON! Press the Horn button to make your car Hop!");
		}
		return 1;
	}



